home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / HackAddict™ Magazine / HA 1-12 / HackAddict08.sit / HackAddict 8 ƒ / HackAddict™ 8.rsrc / TEXT_132.txt < prev    next >
Text File  |  1997-11-30  |  23KB  |  226 lines

  1.    The Ultimate Mac Cracking 
  2.              Guide
  3.  
  4.  
  5.  
  6.      DISCLAMER: I, ProZaq, take NO RESPONSIBILITY for any damage done to your or anyone else‚Äôs computer as a result of following the instructions in this file. I take further NO RESPONSIBILITY for anyone using this file for illegal purposes. If YOU do anything illegal it‚Äôs YOUR SHIT! I intend this file for educational purpouses only. I therefore strongly recomend you registering all sharewares, to keep shareware developers alive, and so that we have a chance against the hughe multi-million-dollar software developing companies! If you decide to use the methods described here for illegal things, don‚Äôt blame me if you get caught!
  7.  
  8.  
  9. --==< Intro >==--
  10.  
  11.      This file is the first part for the complete guide to cracking programs for the Mac. It is planned that when this file is complete it will give a full look at all the ways of cracking programs that I can come up with. There are two references that should be read before reading this article*: ‚ÄúList of Commands‚Äù and ‚ÄúBeginner's Guide to Assembly‚Äù. The former contains a list of the most common 68K Mac assembly commands and the later is a guide to how assembly language works. Before you go on reading, read ‚ÄúBeginner's Guide to Assembly‚Äù, as I asume that anyone reading this already knows assembly! Also, some of you might find this file a bit lenghty and wordy. But remember that I try to describe the methods of cracking thoroughly and in as much detail as possible!
  12.  
  13.  
  14. *Weasel's note: ‚ÄúBeginner's Guide to Assembly‚Äù was included in HackAddict 5. ‚ÄúList of Commands‚Äù is located in ‚ÄúAppendix A: List of Commands‚Äù in this issue. 
  15.  
  16.  
  17. --==< Table of Contents >==--
  18.  
  19. I.       Software you will need
  20. II.      How to Use Macsbug
  21. III.     Exploiting Dialogs
  22. IV.    Using A-traps With Dialogs
  23. V.     How to Crack (in theory)
  24. VI.    How to Crack (in real life)
  25. VII.   End of Part 1
  26.  
  27.  
  28. --==< Software you will need >==--
  29.  
  30.      So what will you need to be a cracker? Well you will need MacsBug, and Super ResEdit (ResEdit with a code editor). MacsBug is a debugger. It was created to allow programers to follow their code through and to find errors and incompabilities. Super ResEdit differs from ResEdit in that it allows you to view the ‚ÄúCODE‚Äù resource as assembly commands (instead of a bunch of hex numbers). MacsBug is included with this archive. Look for Super ResEdit at www.weasel.org (when it is up) or the HackAddict Hotline Site.
  31.  
  32.  
  33. --==< How to Use Macsbug >==--
  34.  
  35.      You install MacsBug simply by throwing it into the system folder, and restarting your machine. You activate it by pressing the ‚Äúcommand‚Äù and ‚Äúpower-key‚Äù (the one towards the top of your keyboard marked with the head of an arrow pointing to the left) buttons. This should have ‚Äúdropped‚Äù you into MacsBug. You will notice that you are in MacBugs ‚Äòcause your desktop is replaced with a with a bunch of numbers on a white background. Well, going from the top left side, under ‚ÄúSP‚Äù is the current position of the stack pointer, underneath the position of the SP are the values contained in the SP. Under those numbers is the name of the application that is currently the foremost active. Under that is the status of the Status Register (he he), followed by the info held in the 8 data registers, and the 8 address registers. To the right of the address registers is a horizontal line going across the screen. Under that are about 4 lines of text. The topmost line discribes where in the
  36. application‚Äôs code the processor was halted. Under that line are 3 other lines with assembly commands. These are the three commands in line to be executed. To the right of them (in the right bottom corner) are the hexadecimal values of the assembly commands. If the topmost assembly command is a conditional such as BEQ then ‚ÄúWill/ Will not branch‚Äù will appear between the command and it‚Äôs hex value. Underneath the ‚ÄúWill/ Will not branch‚Äù is a hex number. ‚ÄúWill branch‚Äù means that the given condition was satisfied and that the program will branch to the address defined by the number underneath the ‚ÄúWill/ Will not branch‚Äù. If it says ‚ÄúWill not branch‚Äù then the number will appear underneath it too. This means that the program will not branch, but continue on with the next command in line. But would it have branched it would have branched to the memory address represented by the hex number. This is a very important concept and it gets important later on! Above this section is a large empty space. This gets filled up with the results of the commands you give to MacsBug. Your commands get written under the three assembly commands.  
  37.  
  38.      What happens when you drop into MacsBug is that your processor stops executing commands, and you can go through a code step by step, command by command, follwoing through exactly what the program does. So how do you do it? Type ‚Äút‚Äù followed by a return.
  39. This causes the processor to execute the next assembly command in line. The assembly command that was executed appears now in the middle blank section of your screen, and a new assembly command appears under the two old ones.
  40.  
  41.  
  42. --==< Basic MacsBug Commands >==--
  43.  
  44.    - t :   traces over the next command in line. If it is used on a JSR command it jumps over the the subroutine. (It executes the whole soubroutine, without allowing you to see what happened)
  45.  
  46.    - s :   does the same thing as ‚Äút‚Äù except it ‚Äústeps into‚Äù a subroutine.  For example if you are not interested in what happens in an subroutine you should type ‚Äút‚Äù. This causes the processor to continue untill it reaches a RTS command, and only then give the controll back to you. If you on the other hand want to see what happens in that subroutine, you should type ‚Äús‚Äù to step into it and follow through the code from there.
  47.  
  48.    - es :     this forces the current application to quit (not always).  
  49.  
  50.    - rs :     restarts your computer (sometimes it doesn work and you have to do it the old fashioned way: apple-control-powerkey)
  51.  
  52.    - rb :     reboots your computer (boots up the different external devices at startup). This is slower then the ‚Äúrb‚Äù command
  53.  
  54.    - dm [address] :      displays what is in the memory at a given address. For example the command ‚Äúdm a6‚Äù shows you what is held in the address pointed to by address register 6. If you type ‚Äúdm abcd‚Äù it shows you what is held in the memory at location ‚Äúabcd‚Äù.
  55.  
  56.    - db [address] :      displays byte from address
  57.  
  58.    - dw [address] :     displays word from address
  59.  
  60.    - dl [address] :       displays long from address
  61.  
  62.    - il :      dissambles the codes. Used if you for example want to see what happens after a branch code.
  63.  
  64.    - atb [a-trap name] :      MacsBug activates every time that a-trap is being called.
  65.  
  66.    - atc :      clears a-traps
  67.  
  68.    - f address expr ‚Äòstring‚Äô :      this is the find command. ‚Äúaddress‚Äù reffers to the starting point of the serch ‚Äúexpr‚Äù is how many bytes it should serch and ‚Äú ‚Äôstring‚Äù is what you‚Äôre looking for! Observe the semi quotation mark before the string! You need to use that!
  69.  
  70. You can find out more about commands for MacsBug by typing ‚Äúhelp‚Äù
  71.  
  72. Super ResEdit is used to a large extent to change the assembly commands and resources in an application. More about it when we need to use it!
  73.  
  74.  
  75. --==< Exploiting Dialogs >==--
  76.  
  77.      All right! Let‚Äôs get started! The first approach to cracking a program is by exploiting the serial number dialog box. Usually when a software asks you to enter a password or serial number, it puts up a dialog box. By dropping into MacsBug you will be able to follow through the code, see what‚Äôs going on, and change the code to fit your needs! The trick with droping into MacsBug is to drop in at the right time. If you don‚Äôt then you‚Äôll probably spend hours following through thousands of commands only to find yourself completely lost! So what is ‚Äúthe right time‚Äù? The right time is dropping into MacsBug right when it starts the routine which checks the serial number. With other words, dropping in at the series of commands, written by the software author, that deal with the registration. So how do you do this? This is when a-traps become important. You see, MacsBug has this function which allows you to automaticly enter MacsBug. if an a-trap is about to be executed. This is the: ‚Äúatb [name of a-trap]‚Äù function. For example you can type: atb getnewdialog followed by a return, and every time the processor is about to run a ‚Äúgetnewdialog‚Äù a-trap you will automaticly be thrown into MacsBug.
  78.  
  79.      Within the Mac OS there are a bunch of a-traps dealing with dialogs.  For example a lot of times dialogs use the ‚ÄúModalDialog‚Äù a-trap. So if you want to drop into MacsBug whenever the ‚Äúmodaldialog‚Äù trap is called you would drop into MacsBug and give it the following command: ‚Äúatb modaldialog‚Äù (without quotes). Whenever you‚Äôre done with a trap, I advise you to give the command ‚Äúatc‚Äù to MacsBug since this turns off the scan for a-traps. 
  80. OK I feel lame so I‚Äôm gonna give you a list of all the a-traps dealing with dialogs (to the best of my knowledge):
  81.  
  82. InitDialogs
  83. ErrorSound
  84. GetNewDialog
  85. CloseDialog
  86. DisposeDialog
  87. CouldDialog
  88. FreeDialog
  89. ParamText
  90. ModalDialog
  91. IsDialogEvent
  92. DialogSelect
  93. DrawDialog
  94. UpdateDialog
  95. Alert
  96. StopAlert
  97. NoteAlert
  98. CautionAlert
  99. CouldAlert
  100. FreeAlert
  101. GetDialogItem
  102. SetDialogItem
  103. HideDialogItem
  104. ShowDialogItem
  105. SelDialogItemText
  106. GetDialogItemText
  107. SetDialogItemText
  108. FindDialogItem
  109. NewColorDialog
  110.  
  111.     The truth is that you don‚Äôt need to learn all of these, but it might come in handy if you have a list of them all. (The a-traps dealing with alerts refer to alert dialog boxes, ie. ones that only have an OK button on them).
  112.  
  113.  
  114. --==< Using A-traps With Dialogs >==--
  115.  
  116.      First I will guide you through the cracking of a program that puts up a registration dialog box and asks you to enter your registration name and registration number.  
  117.  
  118.      The principle behind this is as follows: the program puts up the dialog box, then it lets you enter the registration number (reg#) and your registration name, then it takes your registration name and does a bunch of calculations with it, compares the answere to the reg# you entered, and depending on whether the reg# you entered was right or wrong a conditional branch will occur. Remember what conditionals are? Instructions like: BGE, BNE, BEQ (branch if greater or equal, branch if not equal, branch if equal).  
  119.  
  120.      So what we want to happen is to drop into MacsBug straight after clicking on the OK button, and then trace through the instructions looking for that conditional which decides wether the reg# we entered was right or wrong. And once we found it we want to change it so that no matter what we type as a reg# it will always say that the number we entered is correct!
  121.  
  122.      The most basic approach to this is through the ‚ÄúModalDialog‚Äù a-trap.  Modal dialogs are dialog boxes that are fixed on the screen and only dissapear after you clicked one of the buttons. The only thing you have to know about modal dialog boxes are that information is usually collected from them after the user (cracker) presses the OK button and that the information you typed into the text-fields of the dialog box will be pushed into the memory with the ‚ÄúGetDialogItemText‚Äù a-trap!
  123.  
  124.  
  125. --==< How to Crack (in theory) >==--
  126.  
  127.      So how would I set out to crack the program in real life? I would start off by picking a unique number (that I can easily recognize) such as 123456789. Then I would enter ANY name as the registration name. Then I would type 12345678 (without the nine) as the reg#. Then I would drop into MacsBug and issue the modaldialog trap command (atb modaldialog). Then I would go back to the application with the ‚Äúg‚Äù command. Then I would type the number nine. This should drop me into MacsBug again. The next command is the trace (‚Äút‚Äù) command, which drops me back into the application. Now I would click on the OK button, and find myself in MacsBug. again. And presto, I‚Äôm in the right place. After this it is just a matter of steping and tracing through the code tyring to figure out where the conditional branch I want to change is!  
  128.  
  129. ‚ÄúOK, I think I found the conditional I was looking for...What do I do now?‚Äù Easy! If the conditional does not branch but you want it to branch, type ‚Äúpc=address‚Äù where address represents the hex number under the place where it says ‚ÄúWill branch‚Äù or ‚ÄúWill not branch‚Äù. This should have brought you to a whole new place in the code. After giving the ‚Äúg‚Äù command, the ‚Äúthank you for registering‚Äù dialog should appear if you changed the right conditional! However, sometimes the code will branch when you don‚Äôt want it to. So if you wanted to jump over the current instruction (since not giving the pc a command is like jumping over a command) you would give MacsBug the command ‚Äúpc=pc+n‚Äù, where n is the length om the assembly instruction. How do you determine n? In MacsBug in the right bottom corner next to the assembly instructions are hexadecimal numbers. These numbers are the equivilents to the assembly commands in hexadecimal form. This way you can determine the commands leangth. Just count how many digits the hex number next to the command is, divide it by two and you have the value of n! So if the number is ‚ÄúAAFE‚Äù n would equal 2, and if the number is ‚ÄúAABB 1234‚Äù then n would equal 4. Get it?
  130.  
  131. HINTS:
  132. 1.  The GetDialogItemText a-trap puts the things you entered in the dialog box in address register one. So by checking the value in address register one (give the command ‚Äúdm a1‚Äù) you can decide where the program is collecting the from the dialog, and where it started to mess around with the registration number.
  133.  
  134. 2. Some people would advise you not to stop for ModalDialog a-traps but to do GetDialogItemText or GetDialogItem a-traps straight away. They would argue that this would bring you further into the code. But I don‚Äôt like this approach because the GetDialog commands are usually issued from within subroutines of the main code which means that I have no idea of where in the code I am.  But with the ModalDialog I always know that I‚Äôm at the command after the dialog a-trap.
  135.  
  136. 3. Stepping thorugh the code can become a bitch! I can storongly suggest that you trace through the code at first! Meaning: jump over subroutines, and check which one brings up the dialog saying that the number you entered is invalid. Chances are that the conditional you‚Äôre looking for is in that subroutine. So the next time, step through that subroutine and see what the code does! And if that wasn‚Äôt the right subroutine go to the one before it! This WILL save you a lot of time! 
  137. 3.a) NEVER EVER step into an a-trap! You can reckognize a-traps because they have an ‚Äú_‚Äù sign infront of them. 
  138.  
  139. 4. Pay attention to what‚Äôs going on in the data and address registers! You are following through the code to understand what the program does! If you try the trial and error way, it will probably take you a hell of a long time! So issue the ‚Äúdm [addres]‚Äù command often!
  140.  
  141. So this was the theory, now let‚Äôs do the real thing!
  142.  
  143.  
  144. --==< How to Crack (in real life) >==--
  145.  
  146. This code is take from a real program. But because of copyright issues I will not name the program I took it from! I will just describe the different steps, and what‚Äôs going on! First here is the full code from the ModalDialog trap untill the conditional that I‚Äôm looking for:
  147.  
  148.      +0009A 00D2E6F6   _ModalDialog                          ; 00293126   | A991
  149.      +0009C 00D2E6F8   MOVE.L     -$0004(A6),-(A7)                        | 2F2E FFFC
  150.      +000A0 00D2E6FC   MOVE.W     -$0414(A6),-(A7)                        | 3F2E FBEC
  151.      +000A4 00D2E700   PEA        -$030A(A6)                              | 486E FCF6
  152.      +000A8 00D2E704   PEA        -$0008(A6)                              | 486E FFF8
  153.      +000AC 00D2E708   PEA        -$0312(A6)                              | 486E FCEE
  154.      +000B0 00D2E70C   _GetDialogItem                        ; 00292E38   | A98D
  155.      +000B2 00D2E70E   CMPI.W     #$0001,-$0414(A6)                       | 0C6E 0001 FBEC
  156.      +000B8 00D2E714   BNE        XXXXXXXXX+001AA        ; 00D2E806   | 6600 00F0
  157.      +000BC 00D2E718   MOVEQ      #$01,D3                                 | 7601
  158.      +000BE 00D2E71A   MOVE.L     -$0004(A6),-(A7)                        | 2F2E FFFC
  159.      +000C2 00D2E71E   MOVE.W     #$0006,-(A7)                            | 3F3C 0006
  160.      +000C6 00D2E722   PEA        -$030A(A6)                              | 486E FCF6
  161.      +000CA 00D2E726   PEA        -$0008(A6)                              | 486E FFF8
  162.      +000CE 00D2E72A   PEA        -$0312(A6)                              | 486E FCEE
  163.      +000D2 00D2E72E   _GetDialogItem                        ; 00292E38   | A98D
  164.      +000D4 00D2E730   MOVE.L     -$0008(A6),-(A7)                        | 2F2E FFF8
  165.      +000D8 00D2E734   PEA        -$0412(A6)                              | 486E FBEE
  166.      +000DC 00D2E738   _GetDialogItemText                    ; 002929A4   | A990
  167.      +000DE 00D2E73A   LEA        -$0412(A6),A0                           | 41EE FBEE
  168.      +000E2 00D2E73E   MOVE.L     A0,D3                                   | 2608
  169.      +000E4 00D2E740   MOVEA.L    D3,A0                                   | 2043
  170.      +000E6 00D2E742   MOVEQ      #$00,D0                                 | 7000
  171.      +000E8 00D2E744   MOVE.B     (A0),D0                                 | 1010
  172.      +000EA 00D2E746   ADDQ.L     #$1,D0                                  | 5280
  173.      +000EC 00D2E748   MOVEA.L    D3,A0                                   | 2043
  174.      +000EE 00D2E74A   LEA        -$0308(A6),A1                           | 43EE FCF8
  175.      +000F2 00D2E74E   _BlockMove                            ; 401AD5D8   | A02E
  176.      +000F4 00D2E750   MOVE.L     -$0004(A6),-(A7)                        | 2F2E FFFC
  177.      +000F8 00D2E754   MOVE.W     #$0008,-(A7)                            | 3F3C 0008
  178.      +000FC 00D2E758   PEA        -$030A(A6)                              | 486E FCF6
  179.      +00100 00D2E75C   PEA        -$0008(A6)                              | 486E FFF8
  180.      +00104 00D2E760   PEA        -$0312(A6)                              | 486E FCEE
  181.      +00108 00D2E764   _GetDialogItem                        ; 00292E38   | A98D
  182.      +0010A 00D2E766   MOVE.L     -$0008(A6),-(A7)                        | 2F2E FFF8
  183.      +0010E 00D2E76A   PEA        -$0412(A6)                              | 486E FBEE
  184.      +00112 00D2E76E   _GetDialogItemText                    ; 002929A4   | A990
  185.      +00114 00D2E770   LEA        -$0412(A6),A0                           | 41EE FBEE
  186.      +00118 00D2E774   MOVE.L     A0,D3                                   | 2608
  187.      +0011A 00D2E776   MOVEA.L    D3,A0                                   | 2043
  188.      +0011C 00D2E778   MOVEQ      #$00,D0                                 | 7000
  189.      +0011E 00D2E77A   MOVE.B     (A0),D0                                 | 1010
  190.      +00120 00D2E77C   ADDQ.L     #$1,D0                                  | 5280
  191.      +00122 00D2E77E   MOVEA.L    D3,A0                                   | 2043
  192.      +00124 00D2E780   LEA        -$0108(A6),A1                           | 43EE FEF8
  193.      +00128 00D2E784   _BlockMove                            ; 401AD5D8   | A02E
  194.      +0012A 00D2E786   SUBQ.W     #$2,A7                                  | 554F
  195.      +0012C 00D2E788   PEA        -$0308(A6)                              | 486E FCF8
  196.      +00130 00D2E78C   PEA        -$0108(A6)                              | 486E FEF8
  197.      +00134 00D2E790   JSR        xxxxxxxxxxx                               | 4EB9 00D2 CDD8
  198.      +0013A 00D2E796   MOVE.B     (A7)+,D0                                | 101F
  199.      +0013C 00D2E798   BEQ.S      XXXXXXXXX+00142        ; 00D2E79E   | 6704
  200.  
  201.      Wow! Does that firghten you? Well it shouldn‚Äôt! If you follow the hints I gave you, you should not even have to spend too much time finding the right conditional. OK here‚Äôs a summary of the most important commands from the above exert:
  202.  
  203. + 000B0     GetDialogItem
  204. + 000B8    BNE        XXXXXXXX+001AA              Will Not Branch
  205. + 000D2     GetDialogItem
  206. + 000DC     GetDialogItemText
  207. + 000F2    BlockMove
  208. + 00108    GetDialogItem
  209. + 00112     GetDialogItemText
  210. + 00128    BlockMove
  211. + 00134    JSR        XXXXXX
  212. + 0013C     BEQ        XXXXXXX+00142              Will Branch
  213.  
  214. Ok, so notice the things that I selected to be important! These are the branch commands and the GetDialog a-traps, and the subroutines! An important part of cracking is to reckognize the things you are looking for! And the things you don‚Äôt want to spend time on analyzing! Offcourse the first time you‚Äôre cracking something you will most likely go through each and every command. But as you get better and better you learn to spot the important ones! In the summary the first GetDialogItem trap and the conditional that follows it are unimportant! I reckognized this by branching onto the address given. Since the program froze on me, that was not the conditional I was looking for! The a-trap at offsett DC is the one that puts the name I put as registration name into address register one and the BlockMove probably stores my name somewhere in the memory. At this point I know that the program is still just collecting the data from the dialog. The next couple of a-traps store the number I entered as a reg# in the memory. At this point I know that now the program has all the data it needs and will soon start checking the reg# I entered. And as I expected soon after the BlockMove there is a subroutine. From common sense I guessed that this subroutine is where the program compares my reg# to the real one. So I trace over it. And at 13C is a conditional. It will branch. So I let it branch and see what happens. I find out that all the things I don‚Äôt want to happen, occur. Therefore, I repeat the procedure and come back to this instruction again. But this time I jump over the command. How do I do it? I give MacsBug the command ‚Äúpc=pc+2‚Äù since the hex value of the command is 6704, which is four digits long. This jumps over the command. I issue the command ‚Äúg‚Äù, and voila: the ‚Äúthank you or registering‚Äù dialog appears!
  215.  
  216. As another example, if the conditional above was not BEQ but BNQ, then the program would not have branched. Let‚Äôs say that I wanted it to branch. How do I do it? Easy I just give the command ‚Äúpc=00D2E79E‚Äù since 00D2E79E is the address that appeared under where it says ‚Äúwill not branch‚Äù.
  217.  
  218.  
  219. --==< End of Part 1 >==--
  220.  
  221.     Well folks, that concludes the first part of this file! Do not think that you‚Äôre actually done with cracking the program! But I felt like keeping you in suspense so I will wait ‚Äòtill the next issue of HackAddict to let you know how to actally change the code with ResEdit. In Part 2 of The Ultimate Mac Cracking Guide I will also discribe several more ways of cracking programs that can not be cracked with the ModalDialog trap method!
  222.  
  223.      Part 2 will hopefully be published in the next issue of HackAddict. So until then you‚Äôll have plenty of time for experimenting and getting experienced!
  224.  
  225.  
  226. - ProZaq